<html>
	<head>
		<title>OLAFs Leseecke</title>
		<!--<link rel="stylesheet" type="text/css" href="monitor.css" media="screen" />-->
		<link rel="stylesheet" type="text/css" href="style.css"/>
	</head>
	<?php
		function getCookieArray() {
			if(!isset($_COOKIE['recentBooks']))
				return array();
			$cookie = $_COOKIE['recentBooks'];
			$cookie = stripslashes($cookie);
			$recentBooks = json_decode($cookie, true);
			return $recentBooks;
		}
		
		function saveCookieArray($recentBooks) {
			$json = json_encode($recentBooks, true);
			setcookie('recentBooks', $json);
		}
		
		$recentBooks = getCookieArray();
	?>
	<body>
		<script type="text/javascript" src="wz_tooltip.js"></script>
		<script type="text/javascript" src="sidebarLetters.js"></script>
		<div id="title">
			EBook-Reader
		</div>
		<div id="bar">
			<div id="sidebarLetters-close">
				<a onclick="javaScript: openLetters()"> ||| </a>
			</div>
			<div id="letterlist" isVisible="false">
				<?php
					echo "<a class='letterCur' href='index.php'>&nbsp; @ &nbsp;</a>";
					for($i = 1; $i <= 26; $i++){
						echo "<a class='letter' href='makelist.php?letter=";
						echo chr(64 + $i);
						echo "'>&nbsp; ";
						echo chr(64 + $i);
						echo " &nbsp;</a>";
					}
				?>
			</div>
		</div>
		<div id="content">
			
			<div id="mainlist">
				<p>Zuletzt angesehen:</p>
				<div id="booktbl">
						<?php
							
							while(count($recentBooks) > 0){
								$filename = array_pop($recentBooks);
								if(file_exists("./ebooks/" . $filename . ".jpg"))
									$picfile = "./ebooks/" . $filename . ".jpg";
								else
									$picfile = "./ebooks/nocover.jpg";
								$array = explode("/", $filename);
								$letter = $array[0];
								$file = $array[1] . ".txt";
								$bookatts = explode("-", $array[1]);	
								echo "<a href='show.php?letter=$letter&file=$file'><img class='bild' src='$picfile' alt='$array[1]' onmouseover=\"Tip('&nbsp;$bookatts[0]&nbsp;<br />&nbsp;<br />&nbsp;$bookatts[1]&nbsp;')\" onmouseout=\"UnTip()\" /></a>";
							}
						?>
				</div>
			</div>
		</div>
	</body>
</html>